package inherit;

import java.util.BitSet;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-13
 * Time: 16:26
 */
//super关键字
class Base{
    public int a = 1;
    public int b = 2;

    public void methodA(){
        System.out.println("Base::methodA()");
    }
    public void methodB(){
        System.out.println("Base::methodB()");
    }
}
class Derived extends Base {
    public int a = 3;
    public int d = 4;

    public void methodA(int val){
        System.out.println("Derived::methodA(int)"+val);
    }
    public void methodB(){
        System.out.println("Derived::methodB()");
    }
    public void test(){
        methodA();
        methodA(10);
        methodB();
        super.methodB();
        System.out.println(this.a);
        System.out.println(this.b);
        System.out.println("访问父类的a:"+super.a);
        System.out.println(this.d);
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Derived derived = new Derived();

        derived.test();
    }
}
